package home.conta.list;

import home.conta.divida.Divida;

import java.util.Collections;
import java.util.List;

public class Ordenador {
	
	/**
	 * Ordena lista pelo atributo nome
	 * @param list
	 */
	public static void sortByNome(List<Divida> list){
		NomeComparator comparator = new NomeComparator();
		try {
			Collections.sort(list, comparator);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Ordena lista pelo atributo valor
	 * @param list
	 */
	public static void sortByValor(List<Divida> list){
		ValorComparator comparator = new ValorComparator();
		try {
			Collections.sort(list, comparator);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Ordena lista pelo atributo dataVencimento
	 * @param list
	 */
	public static void sortByDate(List<Divida> list) {
		DateComparator comparator = new DateComparator();
		try {
			Collections.sort(list, comparator);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Ordena lista pelo atributo dataPagamento
	 * @param list
	 */
	public static void sortByDataPagamento(List<Divida> list) {
		DataPagamentoComparator comparator = new DataPagamentoComparator();
		try {
			Collections.sort(list, comparator);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
